// 请求接口
import request from './request'

// 登录接口
export function getLoginApi(data) {
    return request({
        url: '/login',
        method: "POST",
        data
    })
}
// 用户管理接口
export function getUserApi() {
    return request({
        url: '/menus',
        method: "GET",

    })
}
// 用户列表接口
export function getUserListApi(params) {
    return request({
        url: '/users',
        method: 'GET',
        params
    })
}
// 添加用户的接口
export function addUserApi(data) {
    return request({
        url: '/users',
        method: 'POST',
        data
    })
}
// 删除用户的接口
export function delUserApi(userid, data) {
    return request({
        url: `users/${userid}`,
        method: 'DELETE',
        data
    })
}
// 编辑用户的接口
export function editUserApi(userid, data) {
    return request({
        url: `users/${userid}`,
        method: 'PUT',
        data
    })
}
// 开关按钮的状态切换的接口
export function statusUserApi(userid, status) {
    return request({
        url: `users/${userid}/state/${status}`,
        method: 'PUT'
    })
}
// 分配角色的接口
export function sessignRolesApi(userid, rid) {
    return request({
        url: `/users/${userid}/role`,
        method: 'PUT',
        data: {
            rid
        }
    })
}
// 获取用户里面的角色列表接口
export function getUserRolesListApi(userid) {
    return request({
        url: '/roles',
        method: 'GET',
    })
}
// 添加角色的接口
export function addRolesApi(data) {
    return request({
        url: '/roles',
        method: 'POST',
        data
    })
}
// 删除角色的接口
export function delRolesApi(rolesid) {
    return request({
        url: `roles/${rolesid}`,
        method: "DELETE",
    })
}
// 分配权限      权限列表
export function getRightsListApi(type = "list") {
    return request({
        url: `rights/${type}`,
        method: 'GET'
    })
}
// 封装角色授权的接口
export function setRightsToRoleApi(roleid, rids) {
    console.log(roleid);
    return request({
        url: `roles/${roleid}/rights`,
        method: "POST",
        data: {
            rids
        }
    })
}
// 商品列表的接口
export function getGoodsListApi(params) {
    return request({
        url: '/goods',
        method: 'GET',
        params
    })
}
// 删除商品的接口
export function getDelGoodsApi(goodsid) {
    return request({
        url: `/goods/${goodsid}`,
        method: 'DELETE'
    })
}
// 商品分类接口/
export function getGoodsCateListApi(params) {
    return request({
        url: '/categories',
        method: 'GET',
        params
    })
}

// 获取商品参数接口
export function getGoodsParamsApi(cate_id, sel = 'many') {
    return request({
        url: `/categories/${cate_id}/attributes`,
        method: "GET",
        params: {
            sel
        }
    })
}

//添加商品接口
export function addGoodsApi(data) {
    return request({
        url: '/goods',
        method: 'POST',
        data
    })
}

//添加商品分类接口
export function addGoodsCateApi(data) {
    return request({
        url: '/categories',
        method: 'POST',
        data
    })
}

// 编辑提交参数
export function editGoodsParamsApi(id, attrId, data) {
    console.log('这是分类的id', id);
    return request({
        url: `categories/${id}/attributes/${attrId}`,
        method: 'PUT',
        data
    })
}
// 添加动态参数  静态属性
export function addGoodsParamsApi(cateId, data) {
    return request({
        url: `categories/${cateId}/attributes`,
        method: 'POST',
        data
    })
}

// 删除分类接口
export function delGoodsParamsApi(cateId, attrId) {
    return request({
        url: `categories/${cateId}/attributes/${attrId}`,
        method: 'DELETE',

    })
}
// 订单列表
export function getOrdersListApi(params) {
    return request({
        url: '/orders',
        method: 'GET',
        params
    })
}
// 统计表
export function getarrival() {
    return request({
        url: 'reports/type/1',
        method: 'GET',
    })
}